// N1Dictionary.cpp: implementation of the N1Dictionary class.
//
//////////////////////////////////////////////////////////////////////

#include "N1Dictionary.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
using namespace std;

N1Dictionary::N1Dictionary() : m_map2(new MAP), m_map(*m_map2) {
}

N1Dictionary::~N1Dictionary() {
    removeAllObjects();
}

N1UInt32 N1Dictionary::count() const {
    return m_map.size();
}

N1Object* N1Dictionary::objectForKey(N1Object* key) {
    MAP::const_iterator it = m_map.find(key);
    if(it==m_map.end()) return NULL;
    return it->second;
}

N1Array* N1Dictionary::allKeysForObject(N1Object* object) {
    MAP::iterator cur = m_map.begin();
    MAP::iterator end = m_map.end();
    for(;cur!=end;cur++)
    {
    }
    return 0;
}

N1Array* N1Dictionary::allValues() {
    MAP::iterator cur = m_map.begin();
    MAP::iterator end = m_map.end();
    N1Array *arr = new N1Array();
    for(;cur!=end;cur++)
    {
    }
    return (N1Array*)arr->autorelease();
}

bool     N1Dictionary::isEqualToDictionary(const N1Dictionary &dict) const {
    return 0;
}

void N1Dictionary::removeObjectForKey(N1Object* key) {
    MAP::iterator it = m_map.find(key);
    if(it!=m_map.end()) 
        it->second->release();
    m_map.erase( it );
}

void N1Dictionary::removeAllObjects() {
    MAP::iterator cur = m_map.begin();
    MAP::iterator end = m_map.end();
    for(;cur!=end;cur++)
    {
        cur->second->release();
    }
    m_map.clear();
}

void N1Dictionary::setObject(N1Object* key, N1Object* object) {
    m_map.insert(MAP::value_type(key, object));
}
